home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-24 | 29.0 KB | 868 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // Nothing.cp
- // Copyright © 1986-1992 by Apple Computer, Inc. All rights reserved.
- //
- // This is a very small sample application which can save files on disk and can print. The
- // application's windows each contain the word 'MacApp', in large type, and are framed by
- // a large gray border. Documents can be saved on disk and later reopened, but the only
- // document-specific information saved in the disk file is the Print information, which
- // means that if you set print specifications using the Page Setup dialog for a document,
- // and then save the document (using Save As or Save a Copy), those specifications are
- // saved on disk, and when you reopen the document you will find those same print
- // specifications holding for the document. All applications that create views
- // procedurally need to reimplement at least three methods:
- //
- // TApplication.DoMakeDocument -- Launches the appropriate type of Document object
- // TDocument.DoMakeViews -- Launches the appropriate type of View and window objects
- // TView.Draw -- Draws the contents of a view
- //
- // This application, however, consists of the reimplementation of only one method -
- // TView.Draw. This is possible since the view is created from templates; MacApp supplies
- // the default 'view' resource. So in a sense this application is the smallest possible
- // MacApp application.
- //----------------------------------------------------------------------------------------
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #ifndef __MACAPPTYPES__
- #include <MacAppTypes.h>
- #endif
-
- #ifndef __UMACAPPGLOBALS
- #include <UMacAppGlobals.h>
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include <UMacAppUtilities.h>
- #endif
-
- #ifndef __UERRORMGR__
- #include <UErrorMgr.h>
- #endif
-
- #ifndef __UAPPLICATION__
- #include <UApplication.h>
- #endif
-
- #ifndef __UVIEW__
- #include <UView.h>
- #endif
-
- #ifndef __UPRINTING__
- #include <UPrinting.h>
- #endif
-
- //----------------------------------------------------------------------------------------
- // Constants
- //----------------------------------------------------------------------------------------
-
- const OSType kSignature = 'SS01'; // Application signature
- const OSType kFileType = 'SF01'; // File-type code used for document files
- // created by this application
-
-
- //----------------------------------------------------------------------------------------
- // TNothingApplication:
- //----------------------------------------------------------------------------------------
-
- class TNothingApplication : public TApplication
- {
- public:
- virtual pascal void INothingApplication();
- };
-
-
- //----------------------------------------------------------------------------------------
- // TDefaultView:
- //----------------------------------------------------------------------------------------
-
- VRect gBaseViewSize(0, 0, 489, 134);
- VRect gCurrentViewSize(0, 0, 489, 134);
-
- class TDefaultView : public TView
- {
- public:
- virtual pascal void Draw(const VRect& area);
- // Draws the view seen in the window. Every nonblank view MUST override this
- // method.
- virtual pascal void CalcMinFrame( VRect& minFrame);
- virtual pascal void DoKeyEvent( TToolboxEvent* event);
- };
-
- //----------------------------------------------------------------------------------------
- // TBetterWindow:
- //----------------------------------------------------------------------------------------
-
- class TBetterWindow : public TWindow {
- private:
- Boolean fSavePosition;
- Boolean fInDefaultPosition;
-
- public:
- // TObject overrides
- TBetterWindow();
- virtual pascal void Initialize();
- virtual pascal void IBetterWindow( TDocument* itsDocument,
- WindowPtr itsWMgrWindow,
- Boolean canResize,
- Boolean canClose,
- Boolean disposeOnFree);
- virtual pascal void Free();
-
- // no TEventHandler overrides
-
- // no TCommandHandler overrides
-
- // TView overrides
- virtual pascal void DoPostCreate( TDocument* itsDocument);
-
- // TWindow overrides
- virtual pascal void SimpleStagger( CPoint delta,
- short& count);
-
- virtual pascal void GetStandardStateFrame( const VRect& boundingRect,
- VRect& stdFrame);
- virtual pascal void Zoom( short partCode);
- virtual pascal void Close();
-
- virtual pascal void MoveByUser( const VPoint& theMouse);
- virtual pascal void ResizeByUser( const VPoint& theMouse);
- virtual pascal void ZoomByUser( const VPoint& theMouse,
- short partCode);
-
- // new methods
- virtual pascal void MarkPositionAsDirty();
-
- private:
- virtual pascal void GetMonitorInfo( WindowPtr frontWindow,
- CRect& monitorRect);
- virtual pascal void MakePositionUnique( CPoint& newPos,
- CPoint ulhc,
- CPoint delta,
- const CRect& monitorRect);
-
- virtual pascal Boolean IsPositionUnique( CPoint pos);
-
- virtual pascal Boolean WillWindowFit( CPoint pos,
- const CRect& monitorRect);
- virtual pascal Boolean PositionIsSaved();
- virtual pascal Boolean RestorePosition();
- virtual pascal void SavePosition();
- };
-
-
-
- //========================================================================================
- // CLASS TNothingApplication
- //========================================================================================
-
-
- //----------------------------------------------------------------------------------------
- // TNothingApplication::INothingApplication:
- //----------------------------------------------------------------------------------------
- pascal void TNothingApplication::INothingApplication()
- {
- inherited::IApplication(kFileType, kSignature);
-
- // So my view will be substituted when MacApp® creates the "default view"
-
- RegisterStdType("TDefaultView", 'dflt');
- RegisterStdType("TBetterWindow", kStdWindow);
-
- // So the linker doesn't dead strip class info
-
- if (gDeadStripSuppression) {
- macroDontDeadStrip(TDefaultView)
- macroDontDeadStrip(TBetterWindow)
- }
- } // TNothingApplication::INothingApplication
-
-
-
- //========================================================================================
- // CLASS TDefaultView
- //========================================================================================
-
-
- //----------------------------------------------------------------------------------------
- // TDefaultView::Draw:
- //----------------------------------------------------------------------------------------
- pascal void TDefaultView::Draw(const VRect&)
- {
- CStr255 title = "BetterWindow";
- PicHandle thePic;
- CRect qdRect;
- short textWidth;
- CTemporaryRegion saveClip;
-
- this->ViewToQDRect(gBaseViewSize, qdRect);
-
- // remove all clipping while recording the picture
- GetClip(saveClip);
- ClipRect(CRect(-32767, -32767, 32767, 32767));
-
- thePic = OpenPicture(qdRect);
-
- PenNormal();
- PenSize(10, 10);
- PenPat(&qd.dkGray);
-
- // Draw a dark gray frame
- FrameRect(qdRect);
-
- // Set font and size for subsequent display in the window
-
- TextFont(times); // a nice outline font
- TextSize(72);
-
- textWidth = StringWidth(title);
-
- MoveTo(qdRect.left + (qdRect.GetLength(hSel) - textWidth) / 2, 90);
- DrawString(title);
- // Restore the pen state.
- PenNormal();
-
- ClosePicture();
-
- SetClip(saveClip);
-
- this->GetQDExtent(qdRect);
- DrawPicture(thePic, qdRect);
-
- KillPicture(thePic);
- } // TDefaultView::Draw
-
- //----------------------------------------------------------------------------------------
- // TDefaultView::CalcMinFrame:
- //----------------------------------------------------------------------------------------
- pascal void TDefaultView::CalcMinFrame(VRect& minFrame)
- {
- minFrame = gCurrentViewSize;
- } // TDefaultView::CalcMinFrame
-
- //----------------------------------------------------------------------------------------
- // TDefaultView::DoKeyEvent:
- //----------------------------------------------------------------------------------------
- pascal void TDefaultView::DoKeyEvent(TToolboxEvent* event)
- {
- switch (event->fCharacter) {
- case 'u':
- case 'U':
- gCurrentViewSize.right += 50;
- gCurrentViewSize.bottom += 25;
- this->ForceRedraw();
- this->AdjustFrame();
- break;
-
- case 'd':
- case 'D':
- gCurrentViewSize.right -= 50;
- gCurrentViewSize.bottom -= 25;
- this->ForceRedraw();
- this->AdjustFrame();
- break;
-
- default:
- inherited :: DoKeyEvent(event);
- }
- } // TDefaultView::DoKeyEvent
-
-
- //========================================================================================
- // CLASS TBetterWindow
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // INIT AND FREE METHODS
- //----------------------------------------------------------------------------------------
-
- TBetterWindow :: TBetterWindow()
- {
- // empty constructor provided to satisfy compiler
- }
-
- pascal void TBetterWindow :: Initialize()
- // Calls inherited. No unique initialization.
- {
- inherited :: Initialize();
- fSavePosition = false;
- fInDefaultPosition = true;
- }
-
- pascal void TBetterWindow :: IBetterWindow( TDocument* itsDocument,
- WindowPtr itsWMgrWindow,
- Boolean canResize,
- Boolean canClose,
- Boolean disposeOnFree)
- // Calls IWindow. No unique initialization.
- {
- IWindow(itsDocument, itsWMgrWindow, canResize, canClose, disposeOnFree);
- }
-
- pascal void TBetterWindow :: Free()
- // Calls inherited. No unique cleanup.
- {
- inherited :: Free();
- }
-
- //----------------------------------------------------------------------------------------
- // DoPostCreate()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: DoPostCreate( TDocument* itsDocument)
- // Calls inherited. No unique initialization.
- {
- inherited :: DoPostCreate(itsDocument);
- }
-
- //----------------------------------------------------------------------------------------
- // SimpleStagger()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: SimpleStagger( CPoint delta,
- short& /*count*/)
- /*
- This routine replaces the normal window-staggering algorithm with one that is
- more intelligent. Here, every window is, by default, offset from the position
- of the window behind it. If the calculated position is full, we continue to
- offset until we find an open space. If the space we end up with does not allow
- the window to fit entirely on one monitor, we start again at the upper left-hand
- corner of the monitor.
-
- This routine also resizes the standard document or discussion-viewer window to
- fill the screen vertically, and takes care of restoring saved window positions.
- __________________________________________________________________________________
- Parameters:
- delta: The distance to offset the window from its parent.
- count: In the default version of this routine, this is a reference to a
- global that says how many windows have been opened. We don't use it.
-
- */
- {
- CPoint ulhc(7, 20);
- CPoint newPos;
- WindowPtr frontWindow;
- CRect temp;
- CRect monitorRect;
- CPoint localUlhc;
- VRect frame;
-
- // if fStaggered is true, then we've already done all this
- if (this->fStaggered)
- return;
-
- // otherwise, go ahead and set the flag now so we won't go through all this
- // the next time
- this->fStaggered = true;
-
- // tap in here to handle saved positions
- if (PositionIsSaved()) {
- if (RestorePosition())
- return;
- }
-
- // take into account the menu bar when determining where to put the first
- // window
- ulhc.v += *(short*)MBarHeight;
-
- // find the front window and take note of its monitor rectangle
- frontWindow = MAGetActiveWindow();
- GetMonitorInfo(frontWindow, monitorRect);
-
- // if there is no front window, the new window will go in the upper left-hand
- // corner of the main monitor, defined above
- if (frontWindow == NULL) {
- newPos = ulhc;
- localUlhc = ulhc;
- }
-
- // if there is a front window, the new one will be offset from it by the
- // value of "delta" and the upper left-hand corner we use for positioning
- // will be that of the monitor containing the most of the current front
- // window (notice we have to adjust for the menu bar size)
- else {
- temp = (**((WindowPeek)frontWindow)->contRgn).rgnBBox;
- newPos = temp[topLeft];
- newPos += delta;
- localUlhc = ulhc;
- if (monitorRect[topLeft] != gZeroPt) {
- localUlhc += monitorRect[topLeft];
- localUlhc.v -= *(short*)MBarHeight;
- }
- }
- this->MakePositionUnique(newPos, localUlhc, delta, monitorRect);
- this->Locate(VPoint(newPos), false);
-
- /*
- // if this were a text-edit window, the following code would be useful
- if ( [I'm a text-editing window] ) {
- this->GetFrame(frame);
- frame.bottom = monitorRect.bottom - 3;
- this->Resize(frame.GetSize(), false);
- }
- */
- }
-
- //----------------------------------------------------------------------------------------
- // GetStandardStateFrame()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: GetStandardStateFrame( const VRect& /*boundingRect*/,
- VRect& stdFrame)
- /*
- This routine is called by TWindow::Zoom() to get the frame size we're supposed
- to zoom the window to. We ignore the boundingRect passed in, and return the
- window's new frame rectangle in stdFrame.
- __________________________________________________________________________________
- Parameters:
- -> boundingRect: Rectangle we're supposed to zoom to. (not used)
- <- stdFrame: The frame size we're actually going to zoom to (the return
- value).
-
- */
- {
- TView* targetView;
- TScroller* targetScroller;
- VRect targetFrame;
- VRect windowFrame;
- VPoint difference;
- GDHandle monitor;
- CRect tempMonitorRect;
- VRect monitorRect;
- VPoint ulhc(7, 20);
-
- // get the window target view and figure out the difference between its
- // current size and the window's current size (if the window target view is
- // enclosed in a scroller, we're actually interested in the size of the
- // scroller here instead [this probably won't work right if the window
- // target view isn't the only thing in the scroller])
- targetView = (TView*)this->GetWindowTarget();
- targetScroller = targetView->GetScroller(false);
- if (targetScroller == NULL)
- targetView->GetFrame(targetFrame);
- else
- targetScroller->GetFrame(targetFrame);
- this->GetFrame(windowFrame);
- difference = windowFrame.GetSize() - targetFrame.GetSize();
-
- // calculate the target view's minimum frame size, and calculate a new
- // frame rectangle for the window by adding the difference between the window
- // size and the old frame size to the new frame size and making the window
- // frame that new size
- targetView->CalcMinFrame(targetFrame);
- windowFrame[botRight] = windowFrame[topLeft] + targetFrame.GetSize() +
- difference;
- if (windowFrame.GetLength(hSel) < fResizeLimits.left)
- windowFrame.right = windowFrame.left + fResizeLimits.left;
- if (windowFrame.GetLength(vSel) < fResizeLimits.top)
- windowFrame.bottom = windowFrame.top + fResizeLimits.top;
-
- // get the rectangle of the monitor containing the largest part of the
- // window (inset it a little to leave some slop on the sides and to leave
- // room for the menu bar (if we have one) and the window's title bar)
- // [NOTE: GetMaxIntersectedDevice() will usually take the menu bar into
- // account. If it does, the else clause below will automatically adjust
- // ulhc to take the menu bar into account too.]
- monitor = this->GetMaxIntersectedDevice(tempMonitorRect);
- monitorRect = VRect(tempMonitorRect);
- if (monitorRect[topLeft] == gZeroVPt)
- ulhc.v += *(short*)MBarHeight;
- else
- ulhc += monitorRect[topLeft];
- monitorRect[topLeft] = ulhc;
- monitorRect[botRight] -= VPoint(3, 3);
-
- // does the new window frame fit on that monitor? If not, move the window
- // to the upper left-hand corner of the monitor
- if (!monitorRect.Contains(windowFrame)) {
- windowFrame += ulhc - windowFrame[topLeft];
-
- // does it fit now? If not, resize it so that as much of it as possible
- // does
- if (!monitorRect.Contains(windowFrame)) {
- windowFrame.bottom = Min(windowFrame.bottom, monitorRect.bottom);
- windowFrame.right = Min(windowFrame.right, monitorRect.right);
- }
- }
-
- /*
- // if this were a text-editing window, you'd probably want to do this
- if ( [I'm a text-editing window] )
- windowFrame.bottom = monitorRect.bottom;
- */
-
- // and return the result
- stdFrame = windowFrame;
- }
-
- //----------------------------------------------------------------------------------------
- // Zoom()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: Zoom( short partCode)
- /*
- Much as I hate to, I also had to override the TWindow::Zoom() method. The reason
- for this is that the regular zoom code doesn't take into account the possibility
- that the window's standard state might have changed.
-
- That is, if I zoom the window (putting it in its zoomed, or "standard" state)
- and then do something that would change the size of that standard state (such
- as deleting items from it), when I click on the zoom box again, I don't want
- to return to the window's original size (the un-zoomed, or "user" state); I want
- to zoom the window to the new size of its standard state [if you don't believe me,
- look at how window zooming works in the Finder].
-
- Therefore, when I'm going from the standard state back to the user state (partCode
- == inZoomIn), I need to check first to see if the window's standard state has
- changed size. If it has, then the current size becomes the new user state size,
- and I resignal the zoom message on as a change from the (new) user state to the
- (new) standard state (i.e., partCode becomes inZoomOut).
-
- Got that?
- __________________________________________________________________________________
- Parameters:
- partCode: If partCode == inZoomOut, I'm going from the user state to the
- standard state (I'm "zooming the window); if partCode == inZoomIn, I'm
- going from the standard state to the user state ("un-zooming" the window).
-
- */
- {
- VRect curFrame;
- VRect newStdStateFrame;
-
- if (partCode == inZoomOut)
- inherited :: Zoom(partCode);
- else {
- this->GetFrame(curFrame);
- this->GetStandardStateFrame(curFrame, newStdStateFrame); // "curFrame" will be ignored
- if (curFrame == newStdStateFrame)
- inherited :: Zoom(partCode);
- else {
- if (fProcID & zoomDocProc)
- (*((WStateDataHandle)(((WindowPeek)fWMgrWindow)->dataHandle)))->
- userState = curFrame.ToRect();
- inherited :: Zoom(inZoomOut);
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // Close()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: Close()
- /*
- This override is here simply to give me a place to tap in and save off the
- position of the window as it goes down.
- */
- {
- SavePosition();
-
- inherited :: Close();
- }
-
- //----------------------------------------------------------------------------------------
- // USER-INITIAIATED MOVING AND RESIZING ROUTINES
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: MoveByUser( const VPoint& theMouse)
- {
- inherited :: MoveByUser(theMouse);
- fInDefaultPosition = false;
- }
-
- pascal void TBetterWindow :: ResizeByUser( const VPoint& theMouse)
- {
- inherited :: ResizeByUser(theMouse);
- fInDefaultPosition = false;
- }
-
- pascal void TBetterWindow :: ZoomByUser( const VPoint& theMouse,
- short partCode)
- {
- inherited :: ZoomByUser(theMouse, partCode);
- fInDefaultPosition = false;
- }
-
- //----------------------------------------------------------------------------------------
- // MarkPositionAsDirty()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: MarkPositionAsDirty()
- /*
- This routine is here primarily to give external routines (such as the ones that
- change the display parameters) a way to tell the window that it needs to save
- its position again.
- */
- {
- fSavePosition = true;
- }
-
- //----------------------------------------------------------------------------------------
- // GetMonitorInfo()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: GetMonitorInfo( WindowPtr frontWindow,
- CRect& monitorRect)
- /*
- This routine is used by the SimpleStagger() routine to figure out which monitor
- contains the largest part of the current front window and to take note of it
- and its enclosing rectangle. This way, all of SimpleStagger()'s other operations
- will take place only on that monitor.
- __________________________________________________________________________________
- Parameters:
- -> frontWindow: WindowPtr of the frontmost visible window on the screen.
- (NULL if no windows are visible in this application's layer).
- <- monitorRect: Enclosing rectangle (in QD global coordinates) of the
- monitor containing the largest part of the window referenced by
- frontWindow.
- */
- {
- GDHandle monitor;
- GrafPtr wMgrPort;
- TWindow* frontTWindow;
-
- // if we don't have Color QuickDraw, we can't have multiple monitors, so
- // by definition our entire universe is defined by the Window Manager port's
- // portRect
- if (!gConfiguration.hasColorQD) {
- GetWMgrPort(wMgrPort);
- monitorRect = wMgrPort->portRect;
- return;
- }
-
- // if there are no open windows, use the main monitor
- if (frontWindow == NULL) {
- monitor = GetMainDevice();
- monitorRect = (**monitor).gdRect;
- }
-
- // otherwise, use a method in TWindow to find out which monitor contains more
- // of the frontmost window and then get info for it
- else {
- frontTWindow = WMgrToWindow(frontWindow);
- if (frontTWindow == NULL) {
- monitor = GetMainDevice();
- monitorRect = (**monitor).gdRect;
- }
- else {
- monitor = frontTWindow->GetMaxIntersectedDevice(monitorRect);
- monitorRect.top -= *(short*)MBarHeight;
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // MakePositionUnique()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: MakePositionUnique( CPoint& newPos,
- CPoint ulhc,
- CPoint delta,
- const CRect& monitorRect)
- /*
- This routine is used by the SimpleStagger() routine to make sure that the window
- is positioned in a spot that isn't already occupied by another window and that
- the window is positioned entirely on a single monitor.
- __________________________________________________________________________________
- Parameters:
- <-> newPos: On entry, the proposed position for the window. On exit, the
- actual position where the window should go.
- -> ulhc: The upper left-hand corner of the current monitor. This is actually
- the position closest to the monitor's upper left-hand corner where a
- window can be placed.
- -> delta: A point repesenting the amount to offset the window from its parent.
- This value is used when position the window toward the upper left-hand
- corner.
- -> monitorRect: The rectangle defining the current monitor in global
- coordinates.
-
- */
- {
- CPoint workPos(newPos);
- CPoint tempUlhc;
-
- // for as long as the proposed position is on the screen and another window
- // occupies this position, keep advancing down and to the right until we
- // either march off the screen or find an unoccupied position
- while (monitorRect.Contains(workPos) && !IsPositionUnique(workPos))
- workPos += delta;
-
- // if we've marched off the screen or if the unoccupied position won't
- // allow the whole window to be on the screen, try again starting at the
- // monitor's upper left-hand corner
- if (!monitorRect.Contains(workPos) || !WillWindowFit(workPos, monitorRect)) {
- if (newPos != ulhc) {
- workPos = ulhc;
- if (!IsPositionUnique(workPos)) {
- MakePositionUnique(workPos, ulhc, delta, monitorRect);
-
- // if we can't find an unoccupied position that will hold the
- // window after starting at the upper left-hand corner of the
- // monitor, try again, but start halfway between the first two
- // window positions on the monitor (the test here causes
- // recursive calls to fall out if they don't find an acceptable
- // position)
- if (workPos == ulhc) {
- workPos += CPoint(delta.h / 2, delta.v / 2);
-
- if (!IsPositionUnique(workPos)) {
- tempUlhc = workPos;
- MakePositionUnique(workPos, tempUlhc, delta, monitorRect);
-
- // if that doesn't work either, give up and just put the
- // window in the upper left-hand corner of the monitor
- if (workPos == tempUlhc)
- workPos = ulhc;
- }
- }
- }
- }
- else
- workPos = newPos;
- }
-
- // return the new position
- newPos = workPos;
- }
-
- //----------------------------------------------------------------------------------------
- // IsPositionUnique()
- //----------------------------------------------------------------------------------------
-
- pascal Boolean TBetterWindow :: IsPositionUnique( CPoint pos)
- /*
- This routine is used by MakePositionUnique() to determine whether there is
- already a window at the specified position. Returns true if no currently
- visible window in the Window Manager's window list has its upper left-hand
- corner at the position specified by "pos".
- */
- {
- CWMgrIterator iter;
- WindowPtr aWindowPtr;
- CRect windowRect;
-
- for (aWindowPtr = iter.FirstWMgrWindow(); iter.More(); aWindowPtr =
- iter.NextWMgrWindow())
- if ((((WindowPeek)aWindowPtr)->visible) && IsDocumentWindow(aWindowPtr)) {
- windowRect = (**((WindowPeek)aWindowPtr)->contRgn).rgnBBox;
- if (windowRect[topLeft] == pos)
- return false;
- }
- return true;
- }
-
- //----------------------------------------------------------------------------------------
- // WillWindowFit()
- //----------------------------------------------------------------------------------------
-
- pascal Boolean TBetterWindow :: WillWindowFit( CPoint pos,
- const CRect& monitorRect)
- /*
- This routine is used by MakePositionUnique() to determine whether the window
- will fit entirely within the specified monitorRect if its upper left-hand corner
- is placed at "pos". Returns true if the window will fit there, and false if it
- won't.
- */
- {
- CRect frame;
-
- frame[topLeft] = pos;
- frame[botRight] = pos + this->fSize.ToPoint();
-
- // the insetting here takes into account the frame and drop shadow (we don't
- // care about the title bar, since we're always going down and to the right
- // and we know we started in a position where the title bar will work)
- frame.Inset(CPoint(-2, -2));
-
- return monitorRect.Contains(frame);
- }
-
- //----------------------------------------------------------------------------------------
- // PositionIsSaved()
- //----------------------------------------------------------------------------------------
-
- pascal Boolean TBetterWindow :: PositionIsSaved()
- {
- /*
- This routine and the two below are left as an exercise for the reader.
- My original version of this is proprietary. The way we save and restore
- window positions is specific to the kind of application we were
- writing and can't be generalized.
- */
-
- return false;
- }
-
- //----------------------------------------------------------------------------------------
- // RestorePosition()
- //----------------------------------------------------------------------------------------
-
- pascal Boolean TBetterWindow :: RestorePosition()
- {
- // see comment in PositionIsSaved()
-
- return false;
- }
-
- //----------------------------------------------------------------------------------------
- // SavePosition()
- //----------------------------------------------------------------------------------------
-
- pascal void TBetterWindow :: SavePosition()
- {
- // see comment in PositionIsSaved()
- }
-
-
- //========================================================================================
- // GLOBAL Procedures
- //========================================================================================
-
-
- //----------------------------------------------------------------------------------------
- // Globals
- //----------------------------------------------------------------------------------------
- TNothingApplication *gNothingApplication; // The application object
-
-
- //----------------------------------------------------------------------------------------
- // main:
- //----------------------------------------------------------------------------------------
- #pragma push
- #pragma processor 68000
- #pragma segment Main
-
- void main()
- {
- InitToolBox();
-
- if (ValidateConfiguration(gConfiguration))
- {
- InitUMacApp(8); // Initialize MacApp; 8 calls to MoreMasters
-
- InitUPrinting();
-
- gNothingApplication = new TNothingApplication;
- gNothingApplication->INothingApplication();
-
- gNothingApplication->Run();
- }
- else
- StdAlert(phUnsupportedConfiguration);
- } // main
-
- #pragma pop
-
-
-